<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/docs.css" type="text/css" rel="stylesheet" />
<link href="../css/prettify.css" type="text/css" rel="stylesheet" />
<script src="../js/prettify.js" type="text/javascript"></script>
</head>
<body onLoad="prettyPrint()">
<div class="g-unit" id="doc-content">
<div id="api-info-block">
    <div class="api-level">H3C CAS云管理平台</div>
  </div>
  <div id="jd-header">
    <h1>创建虚拟机</h1>
  </div>
</div>
<div id="jd-content">
<div class="jd-descr">
<p>根据指定的参数创建虚拟机。</p>
<h2><a name="uri"></a>接口 URI</h2>
<p>/cas/casrs/vm/add</p>
<h2><a name="access"></a>访问方法</h2>
<dl>
  <dt><b>HTTP 方法</b></dt>
  <dd>POST</dd>
  <dt><b>消息体</b></dt>
  <div class="source">
  	<pre class="prettyprint lang-xml">&lt;domain&gt;<br>    &lt;name&gt;rest-add-vm&lt;/name&gt;<br>    &lt;title&gt;rest-add-vm测试&lt;/title&gt;<br>    &lt;description&gt;rest add vm&lt;/description&gt;<br>    &lt;memory&gt;1024&lt;/memory&gt;<br>    &lt;memoryInit&gt;1.0&lt;/memoryInit&gt;<br>    &lt;memoryUnit&gt;GB&lt;/memoryUnit&gt;<br>    &lt;memoryBacking&gt;0&lt;/memoryBacking&gt;<br>    &lt;memoryPriority&gt;0&lt;/memoryPriority&gt;<br>    &lt;cpuSockets&gt;2&lt;/cpuSockets&gt;<br>    &lt;cpuCores&gt;1&lt;/cpuCores&gt;<br>    &lt;cpuShares&gt;512&lt;/cpuShares&gt;<br>    &lt;cpuGurantee&gt;0&lt;/cpuGurantee&gt;<br>    &lt;maxCpuSocket&gt;64&lt;/maxCpuSocket&gt;<br>    &lt;hostId&gt;1&lt;/hostId&gt;<br>    &lt;hostPoolId&gt;1&lt;/hostPoolId&gt;<br>    &lt;description&gt;&lt;/description&gt;<br>    &lt;blkiotune&gt;300&lt;/blkiotune&gt;<br>    &lt;autoMigrate&gt;1&lt;/autoMigrate&gt;<br>    &lt;uuid&gt;&lt;/uuid&gt;<br>    &lt;osBit&gt;x86_64&lt;/osBit&gt;<br>    &lt;system&gt;0&lt;/system&gt;<br>    &lt;osVersion&gt;Microsoft Windows Server 2008 R2(64-bit)&lt;/osVersion&gt;<br>    &lt;formatEnable&gt;1&lt;/formatEnable&gt;<br>    &lt;bindcpu&gt;<br>        &lt;vcpu&gt;0&lt;/vcpu&gt;<br>        &lt;pcpu&gt;0&lt;/pcpu&gt;<br>        &lt;pcpu&gt;1&lt;/pcpu&gt;<br>    &lt;/bindcpu&gt;<br>    &lt;bindcpu&gt;<br>        &lt;vcpu&gt;1&lt;/vcpu&gt;<br>        &lt;pcpu&gt;0&lt;/pcpu&gt;<br>        &lt;pcpu&gt;1&lt;/pcpu&gt;<br>    &lt;/bindcpu&gt;<br>    &lt;network&gt;<br>        &lt;vsId&gt;1&lt;/vsId&gt;<br>        &lt;vsName&gt;vswitch0&lt;/vsName&gt;<br>        &lt;deviceModel&gt;virtio&lt;/deviceModel&gt;<br>        &lt;isKernelAccelerated&gt;1&lt;/isKernelAccelerated&gt;<br>        &lt;mode&gt;veb&lt;/mode&gt;<br>        &lt;profileId&gt;1&lt;/profileId&gt;<br>    &lt;/network&gt;<br>    &lt;network><br>        &lt;mac>0c:da:41:1d:75:9b&lt;/mac><br>        &lt;driverType>VFIO&lt;/driverType><br>        &lt;ethName>eth3&lt;/ethName><br>        &lt;address>0000:07:09.0&lt;/address><br>        &lt;deviceModel>SR_IOV&lt;/deviceModel><br>        &lt;vlan>1&lt;/vlan><br>    &lt;/network><br>    &lt;storage&gt;<br>        &lt;storeFile&gt;/vms/images/ubunt-test.10_ubuntu_0_ubunt-test_003&lt;/storeFile&gt;<br>        &lt;capacity&gt;15&lt;/capacity&gt;<br>        &lt;targetBus&gt;virtio&lt;/targetBus&gt;<br>        &lt;type&gt;file&lt;/type&gt;<br>        &lt;device&gt;disk&lt;/device&gt;<br>        &lt;driveType&gt;qcow2&lt;/driveType&gt;<br>        &lt;assignType&gt;0&lt;/assignType&gt;<br>        &lt;cacheType&gt;directsync&lt;/cacheType&gt;<br>    &lt;/storage&gt;<br>    &lt;storage&gt;<br>        &lt;storeFile&gt;/vms/isos/castools.iso&lt;/storeFile&gt;<br>        &lt;device&gt;cdrom&lt;/device&gt;<br>    &lt;/storage&gt;<br>    &lt;storage&gt;<br>        &lt;storeFile&gt;autoVirtio&lt;/storeFile&gt;<br>        &lt;device&gt;floppy&lt;/device&gt;<br>    &lt;/storage&gt;
    &lt;usb&gt;<br>        &lt;devName&gt;usb_usb3&lt;/devName&gt;<br>        &lt;vendorId&gt;0x1d6b&lt;/vendorId&gt;<br>        &lt;vendor&gt;Linux 3.13.6 uhci_hcd&lt;/vendor&gt;<br>        &lt;productId&gt;0x0001&lt;/productId&gt;<br>        &lt;product&gt;UHCI Host Controller&lt;/product&gt;<br>        &lt;bus&gt;3&lt;/bus&gt;<br>        &lt;device&gt;1&lt;/device&gt;<br>        &lt;controller&gt;2&lt;/controller&gt;<br>    &lt;/usb&gt;<br>    &lt;pci&gt;<br>        &lt;devName&gt;pci_0000_03_00_2&lt;/devName&gt;<br>        &lt;driver&gt;KVM&lt;/driver&gt;<br>        &lt;bus&gt;3&lt;/bus&gt;<br>        &lt;slot&gt;0&lt;/slot&gt;<br>        &lt;function&gt;2&lt;/function&gt;<br>        &lt;vendorId&gt;0x14e4&lt;/vendorId&gt;<br>        &lt;vendor&gt;Broadcom Corporation&lt;/vendor&gt;<br>        &lt;productId&gt;0x1657&lt;/productId&gt;<br>        &lt;product&gt;NetXtreme BCM5719 Gigabit Ethernet PCIe&lt;/product&gt;<br>        &lt;ethName&gt;eth2&lt;/ethName&gt;<br>    &lt;/pci&gt;<br>    &lt;gpu&gt;<br>        &lt;resPoolId&gt;1&lt;/resPoolId&gt;<br>        &lt;businessTemId&gt;2&lt;/businessTemId&gt;<br>    &lt;/gpu&gt;<br>&lt;/domain&gt;</pre>
  </div>
</dl>

<dt><a name="detail"></a><b>元素含义</b></dt>
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2"><span class="prettyprint lang-xml">domain</span>各子元素</th>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">name</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">虚拟机名称，名称的最大输入长度为64个字符，且只允许输入字母、数字、减号、下划线及点。</span>
            <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
      
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">title</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟机显示名称，最大输入长度为64个字符。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
      
      <tr class="alt-color">
        <td class="alt-color"><span class="prettyprint lang-xml">description</span></td>
        <td class="jd-linkcol"><span class="sympad">描述,最大输入长度为120个字符。</span>
          <div class="jd-descrdiv">字符串（String）类型，可选项。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">memory</span></td>
        <td class="jd-linkcol"><span class="sympad">内存大小，单位为MB，最小值为512最大值由主机实际情况决定。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
	        <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">memoryInit</span></td>
        <td class="jd-linkcol"><span class="sympad">内存大小，单位为由memoryUnit决定,换算成MB后，必须与memory指定的值相同。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
	   <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">memoryUnit</span></td>
        <td class="jd-linkcol"><span class="sympad">内存显示单位，字符串。</span>
            <div class="jd-descrdiv">枚举类型：GB,MB。</div></td>
      </tr>
       <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">memoryPriority</span></td>
        <td class="jd-linkcol"><span class="sympad">内存资源优先级。枚举值：0=低，50=中，100=高</span>
          <div class="jd-descrdiv">整型（Integer）类型，取值:0,50,100。必填。</div></td>
      </tr>
	         <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">memoryBacking</span></td>
        <td class="jd-linkcol"><span class="sympad">内存预留。内存预留百分比。</span>
          <div class="jd-descrdiv">整型（Integer）类型，取值范围:0-100。必填。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">cpuSockets</span></td>
        <td class="jd-linkcol"><span class="sympad">CPU个数，最小值为1，最大值由主机实际情况决定。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">cpuCores</span></td>
        <td class="jd-linkcol"><span class="sympad">CPU核数，最小值为1，最大值由主机实际情况决定。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">cpuShares</span></td>
        <td class="jd-linkcol"><span class="sympad">CPU调度优先级，枚举值：1024：高，512：中，256：低。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">maxCpuSocket</span></td>
        <td class="jd-linkcol"><span class="sympad">主机允许的最大CPU核数。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">blkiotune</span></td>
        <td class="jd-linkcol"><span class="sympad">I/O优先级，枚举值：500：高，300：中，200：低。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">system</span></td>
        <td class="jd-linkcol"><span class="sympad">操作系统类型，枚举值：0：Windows,1：Linux。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
	   <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">osVersion</span></td>
        <td class="jd-linkcol"><p class="sympad">操作系统版本，枚举值：</p>
          <p class="sympad">当操作系统为Windows:</p>
          <p class="sympad">Microsoft Windows Server 2012, Microsoft Windows Server 2012 R2, Microsoft Windows Server 2008 R2(64-bit), Microsoft Windows Server 2008(64-bit), Microsoft Windows Server 2008(32-bit), Microsoft Windows Server 2003(64-bit), Microsoft Windows Server 2003(32-bit), Microsoft Windows 8(64-bit), Microsoft Windows 8(32-bit), Microsoft Windows 7(64-bit), Microsoft Windows 7(32-bit), Microsoft Windows Vista(64-bit), Microsoft Windows Vista(32-bit), Microsoft Windows XP Professional(64-bit), Microsoft Windows XP Professional(32-bit), Microsoft Windows 2000, Microsoft Windows NT, Microsoft Windows 98, Microsoft Windows 95, Microsoft Windows 3.1, Microsoft MS-DOS
            </p>
			<p class="sympad">当操作系统为Linux:</p>
          <p class="sympad">Red Hat Enterprise Linux7(64-bit), Red Hat Enterprise Linux7(32-bit), Red Hat Enterprise Linux6(64-bit), Red Hat Enterprise Linux6(32-bit), Red Hat Enterprise Linux5(64-bit), Red Hat Enterprise Linux5(32-bit), Red Hat Enterprise Linux4(64-bit), Red Hat Enterprise Linux4(32-bit), Red Hat Enterprise Linux3(64-bit), Red Hat Enterprise Linux3(32-bit), Red Hat Enterprise Linux2.1, Novell SUSE Linux Enterprise 11(64-bit), Novell SUSE Linux Enterprise 11(32-bit), Novell SUSE Linux Enterprise 10(64-bit), Novell SUSE Linux Enterprise 10(32-bit), Novell SUSE Linux Enterprise 8/9(64-bit), Novell SUSE Linux Enterprise 8/9(32-bit), CentOS 4/5/6(64bit), CentOS 4/5/6(32bit), Debian GUN/Linux 6(64-bit), Debian GUN/Linux 6(32-bit), Debian GUN/Linux 5(64-bit), Debian GUN/Linux 5(32-bit), Debian GUN/Linux 4(64-bit), Debian GUN/Linux 4(32-bit), Asianux 4(64-bit), Asianux 4(32-bit), Asianux 3(64-bit), Asianux 3(32-bit), Oracle Linux 4/5/6(64-bit), Oracle Linux 4/5/6(32-bit), Ubuntu Linux(64-bit), Ubuntu Linux(32-bit), Other 2.6.x Linux(64-bit), Other 2.6.x Linux(32-bit), Other 2.4.x Linux(64-bit), Other 2.4.x Linux(32-bit), Other Linux(64-bit), Other Linux(32-bit)</p>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">autoMigrate</span></td>
        <td class="jd-linkcol"><span class="sympad">是否允许虚拟机自动迁移，实现资源动态调整，枚举值：1=允许，0=不允许。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">priority</span></td>
        <td class="jd-linkcol"><span class="sympad">启动优先级，当集群启用HA后有效，枚举值：0：低级，1：中级，2：高级。</span>
            <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">hostId</span></td>
        <td class="jd-linkcol"><span class="sympad">主机id。</span>
            <div class="jd-descrdiv">长整型（Long）类型，必须。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">hostPoolId</span></td>
        <td class="jd-linkcol"><span class="sympad">主机池id。</span>
            <div class="jd-descrdiv">长整型（Long）类型，必须。</div></td>
      </tr>
	  
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">formatEnable</span></td>
        <td class="jd-linkcol"><span class="sympad">是否可用。</span>
            <div class="jd-descrdiv">整型（Integer）类型，设置为1，必须。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">bindcpu</span></td>
        <td class="jd-linkcol"><span class="sympad">绑定物理CPU配置。</span>
            <div class="jd-descrdiv">自定义类型<span class="sympad">，可选项</span>。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">network</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟机网络配置。</span>
            <div class="jd-descrdiv">自定义类型<span class="sympad">，必须</span>。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">storage</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟机存储配置。</span>
            <div class="jd-descrdiv">自定义类型，必须。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">usb</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟机USB设备配置。</span>
            <div class="jd-descrdiv">自定义类型，可选。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">pci</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟机PCI设备配置。</span>
            <div class="jd-descrdiv">自定义类型，可选。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">gpu</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟机GPU直通显卡配置,最多只能有一个。</span>
            <div class="jd-descrdiv">自定义类型，可选。</div></td>
      </tr>
    </table>
	<table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2">bindcpu各子元素</th>
      </tr>
      
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">vcpu</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">指定虚拟CPU，0：表示第一个虚拟CPU，1：表示第二个虚拟CPU，依次类推。</span>
          <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">pcpu</span></td>
        <td class="jd-linkcol"><span class="sympad">指定物理CPU，0：表示第一个物理CPU，1：表示第二个物理CPU，依次类推。一个虚拟CPU可绑定多个物理CPU。</span>
          <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
  </table>
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2">network各子元素(非SR-IOV网卡)</th>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">deviceModel</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">网卡设备型号，枚举值：rtl8139：普通网卡;virtio：Virtio网卡;e1000：Intel e1000网卡。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">vsId</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟交换机id。</span>
          <div class="jd-descrdiv">长整型（Long）类型，必须。</div></td>
      </tr>
	  
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">vsName</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟交换机名称。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">profileId</span></td>
        <td class="jd-linkcol"><span class="sympad">网络策略模板id。</span>
          <div class="jd-descrdiv">长整型（Long）类型，必须。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">isKernelAccelerated</span></td>
        <td class="jd-linkcol"><span class="sympad">是否设置内核加速，枚举值：1：代表设置内核加速，0：代表不设置。</span>
          <div class="jd-descrdiv">整型（Integer）类型，默认为0。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">ipAddr</span></td>
        <td class="jd-linkcol"><span class="sympad">网卡绑定IP地址。</span>
          <div class="jd-descrdiv">字符串（String）类型，符合IPv4格式，可选项。</div></td>
      </tr>
  </table>
    <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2">network各子元素(SR-IOV网卡)</th>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">deviceModel</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">网卡设备型号，SR_IOV:SR-IOV直通网卡。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">driverType</span></td>
        <td class="jd-linkcol"><span class="sympad">驱动类型，枚举值：VFIO：VFIO设备分配处理，KVM：KVM内核处理</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">address</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟网卡地址。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">ethName</span></td>
        <td class="jd-linkcol"><span class="sympad">SR-IOV直通网卡名称。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">mac</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟网卡mac地址</span>
          <div class="jd-descrdiv">字符串（String）类型，可选项。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">vlan</span></td>
        <td class="jd-linkcol"><span class="sympad">vlan</span>
          <div class="jd-descrdiv">整型（Integer）类型，可选项。</div></td>
      </tr>
  </table>
  
    <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2">storage各子元素</th>
      </tr>
        <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">device</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">存储类型，枚举值：disk：硬盘， cdrom：光驱， floppy：软驱。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">targetBus</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">存储设备类型，枚举值：ide：IDE硬盘， scsi：SCSI硬盘， usb：USB硬盘;，virtio：Virtio 硬盘。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">storeFile</span></td>
        <td class="jd-linkcol"><span class="sympad">存储文件路径,当增加软驱时，若值为autoVirtio，则根据操作系统类型自动加载一个软驱设备。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">cacheType</span></td>
        <td class="jd-linkcol"><span class="sympad">磁盘缓存方，枚举值：directsync，writethrough，writeback，none。</span>
          <div class="jd-descrdiv">字符串（String）类型，当存储卷为文件类型时不能为空。</div></td>
      </tr>
	  
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">assignType</span></td>
        <td class="jd-linkcol"><span class="sympad">分配类型:0指定 1动态分配。</span>
          <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
	  
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">type</span></td>
        <td class="jd-linkcol"><span class="sympad">类型。枚举值：file 文件， block 块设备。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	    <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">driveType</span></td>
        <td class="jd-linkcol"><span class="sympad">存储卷类型，必须和使用的存储卷的类型保持一致，枚举值：qcow2，raw</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
  </table>
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2">usb各子元素</th>
      </tr>
      
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">devName</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">USB设备名称，必须与主机上查询的USB名称一致。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">vendorId</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">USB设备的vendorId的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">vendor</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">USB设备的vendor的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">productId</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">USB设备的productId的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">product</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">USB设备的product的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	   <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">bus</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">USB设备的bus的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	   <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">device</span></td>
       <td width="100%" class="jd-linkcol"><span class="sympad">USB设备的device的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	   <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">controller</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">USB控制器版本，取值为1：USB1.0,2：USB2.0,3：USB3.0。</span>
          <div class="jd-descrdiv">整型（Integer）类型，必须。</div></td>
      </tr>
  </table>
    <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2">pci各子元素</th>
      </tr>
      
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">devName</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">PCI设备名称，必须与主机上查询的PCI名称一致。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">vendorId</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">PCI设备的vendorId的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">vendor</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">PCI设备的vendor的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">productId</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">PCI设备的productId的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	  	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">product</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">PCI设备的product的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	 <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">function</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">PCI设备的function的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	<tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">slot</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">PCI设备的slot的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	   <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">bus</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">PCI设备的bus的值。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	   <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">ethName</span></td>
       <td width="100%" class="jd-linkcol"><span class="sympad">PCI物理接口的名称。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
	   <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">driver</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">驱动类型，取值为：KVM,VFIO。</span>
          <div class="jd-descrdiv">字符串（String）类型，必须。</div></td>
      </tr>
  </table>
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2">gpu各子元素</th>
      </tr>
      
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">resPoolId</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">GPU资源池ID。</span>
          <div class="jd-descrdiv">长整型（Long）类型，必须。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">businessTemId</span></td>
        <td class="jd-linkcol"><span class="sympad">业务模板ID。</span>
          <div class="jd-descrdiv">长整型（Long）类型，必须。</div></td>
      </tr>
  </table>

<h2><a name="result"></a>返回结果</h2>
<dl>
  <dt><b>状态码</b></dt>
  <dd>
  <ul>
    <li>200(OK)：成功。</li>
    <li>409(Conflict)：失败。 </li>
  </ul>
  </dd>
  <dt><b>回应</b></dt>
  <div class="source"><pre class="prettyprint lang-xml">HTTP/1.1 200 OK<br>Server: Apache-Coyote/1.1<br>Content-Type: application/xml<br>Content-Length: 216<br>Date: Mon, 25 Nov 2013 08:25:58 GMT
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;taskMsg&gt;<br>  &lt;msgId&gt;1393831560400&lt;/msgId&gt;<br>  &lt;targetId&gt;3&lt;/targetId&gt;<br>  &lt;targetName&gt;vm110-1&lt;/targetName&gt;<br>  &lt;completed&gt;false&lt;/completed&gt;<br>  &lt;progress&gt;0&lt;/progress&gt;<br>&lt;/taskMsg&gt;</pre>
  </div>
  <dt>&nbsp;</dt>
  
</dl>
<dt><a name="detail"></a><b>元素含义</b></dt>
    <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2">返回创建虚拟机任务id，可根据任务id查询任务进度。</th>
      </tr>
  </table>
    <h2><a name="example"></a>应用举例</h2>
    <p>创建虚拟机rest_add2u，并配置CPU绑定物理网卡，绑定虚拟机IP。</p>
    <dl>
      <dt><b>请求</b></dt>
      <div class="source">
        <pre class="prettyprint lang-xml">POST http://192.168.0.4:8080/cas/casrs/vm/add
accept: application/xml


&lt;domain&gt;<br>    &lt;name&gt;rest-add-vm&lt;/name&gt;<br>    &lt;title&gt;rest-add-vm测试&lt;/title&gt;<br>    &lt;description&gt;rest add vm&lt;/description&gt;<br>    &lt;memory&gt;1024&lt;/memory&gt;<br>    &lt;memoryInit&gt;1.0&lt;/memoryInit&gt;<br>    &lt;memoryUnit&gt;GB&lt;/memoryUnit&gt;<br>    &lt;memoryBacking&gt;0&lt;/memoryBacking&gt;<br>    &lt;memoryPriority&gt;0&lt;/memoryPriority&gt;<br>    &lt;cpuSockets&gt;2&lt;/cpuSockets&gt;<br>    &lt;cpuCores&gt;1&lt;/cpuCores&gt;<br>    &lt;cpuShares&gt;512&lt;/cpuShares&gt;<br>    &lt;cpuGurantee&gt;0&lt;/cpuGurantee&gt;<br>    &lt;maxCpuSocket&gt;64&lt;/maxCpuSocket&gt;<br>    &lt;hostId&gt;1&lt;/hostId&gt;<br>    &lt;hostPoolId&gt;1&lt;/hostPoolId&gt;<br>    &lt;description&gt;&lt;/description&gt;<br>    &lt;blkiotune&gt;300&lt;/blkiotune&gt;<br>    &lt;autoMigrate&gt;1&lt;/autoMigrate&gt;<br>    &lt;uuid&gt;&lt;/uuid&gt;<br>    &lt;osBit&gt;x86_64&lt;/osBit&gt;<br>    &lt;system&gt;0&lt;/system&gt;<br>    &lt;osVersion&gt;Microsoft Windows Server 2008 R2(64-bit)&lt;/osVersion&gt;<br>    &lt;formatEnable&gt;1&lt;/formatEnable&gt;<br>    &lt;bindcpu&gt;<br>        &lt;vcpu&gt;0&lt;/vcpu&gt;<br>        &lt;pcpu&gt;0&lt;/pcpu&gt;<br>        &lt;pcpu&gt;1&lt;/pcpu&gt;<br>    &lt;/bindcpu&gt;<br>    &lt;bindcpu&gt;<br>        &lt;vcpu&gt;1&lt;/vcpu&gt;<br>        &lt;pcpu&gt;0&lt;/pcpu&gt;<br>        &lt;pcpu&gt;1&lt;/pcpu&gt;<br>    &lt;/bindcpu&gt;<br>    &lt;network&gt;<br>        &lt;vsId&gt;1&lt;/vsId&gt;<br>        &lt;vsName&gt;vswitch0&lt;/vsName&gt;<br>        &lt;deviceModel&gt;virtio&lt;/deviceModel&gt;<br>        &lt;isKernelAccelerated&gt;1&lt;/isKernelAccelerated&gt;<br>        &lt;mode&gt;veb&lt;/mode&gt;<br>        &lt;profileId&gt;1&lt;/profileId&gt;<br>    &lt;/network&gt;<br>    &lt;storage&gt;<br>        &lt;storeFile&gt;/vms/images/ubunt-test.10_ubuntu_0_ubunt-test_003&lt;/storeFile&gt;<br>        &lt;capacity&gt;15&lt;/capacity&gt;<br>        &lt;targetBus&gt;virtio&lt;/targetBus&gt;<br>        &lt;type&gt;file&lt;/type&gt;<br>        &lt;device&gt;disk&lt;/device&gt;<br>        &lt;driveType&gt;qcow2&lt;/driveType&gt;<br>        &lt;assignType&gt;0&lt;/assignType&gt;<br>        &lt;cacheType&gt;directsync&lt;/cacheType&gt;<br>    &lt;/storage&gt;<br>    &lt;storage&gt;<br>        &lt;storeFile&gt;/vms/isos/castools.iso&lt;/storeFile&gt;<br>        &lt;device&gt;cdrom&lt;/device&gt;<br>    &lt;/storage&gt;<br>    &lt;storage&gt;<br>        &lt;storeFile&gt;autoVirtio&lt;/storeFile&gt;<br>        &lt;device&gt;floppy&lt;/device&gt;<br>    &lt;/storage&gt;<br>&lt;/domain&gt;
</pre>
      </div>
      <dt><b>回应</b></dt>
      <div class="source"><pre class="prettyprint lang-xml">HTTP/1.1 200 OK<br>Server: Apache-Coyote/1.1<br>Content-Type: application/xml<br>Transfer-Encoding: chunked<br>Date: Mon, 25 Nov 2013 11:44:05 GMT<br/>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;taskMsg&gt;<br>  &lt;msgId&gt;1393831560400&lt;/msgId&gt;<br>  &lt;targetId&gt;3&lt;/targetId&gt;<br>  &lt;targetName&gt;vm110-1&lt;/targetName&gt;<br>  &lt;completed&gt;false&lt;/completed&gt;<br>  &lt;progress&gt;0&lt;/progress&gt;<br>&lt;/taskMsg&gt;</pre>
      </div>
    </dl>
    
</div>
</div>
</div>
</body>
</html>